var ImgIputHandler={
	facePath:[
	    {faceName:"微笑",facePath:"weixiao.gif"},
		{faceName:"撇嘴",facePath:"piezui.gif"},
		{faceName:"色",facePath:"se.gif"},
		{faceName:"发呆",facePath:"fadai.gif"},
		{faceName:"得意",facePath:"deyi.gif"},
		{faceName:"流泪",facePath:"liulei.gif"},
		{faceName:"害羞",facePath:"haixiu.gif"},
		{faceName:"闭嘴",facePath:"bizui.gif"},
		{faceName:"大哭",facePath:"daku.gif"},
		{faceName:"尴尬",facePath:"ganga.gif"},
		{faceName:"发怒",facePath:"fanu.gif"},
		{faceName:"调皮",facePath:"tiaopi.gif"},
		{faceName:"龇牙",facePath:"ziya.gif"},
		{faceName:"惊讶",facePath:"jingya.gif"},
		{faceName:"难过",facePath:"nanguo.gif"},
		{faceName:"酷",facePath:"ku.gif"},
		{faceName:"冷汗",facePath:"lenghan.gif"},
		{faceName:"抓狂",facePath:"zhuakuang.gif"},
		{faceName:"吐",facePath:"tu.gif"},
		{faceName:"偷笑",facePath:"touxiao.gif"},
	    {faceName:"可爱",facePath:"keai.gif"},
		{faceName:"白眼",facePath:"baiyan.gif"},
		{faceName:"傲慢",facePath:"aoman.gif"},
		{faceName:"饥饿",facePath:"jie.gif"},
		{faceName:"困",facePath:"kun.gif"},
		{faceName:"惊恐",facePath:"jingkong.gif"},
		{faceName:"流汗",facePath:"liuhan.gif"},
		{faceName:"憨笑",facePath:"hanxiao.gif"},
		{faceName:"大兵",facePath:"dabing.gif"},
		{faceName:"奋斗",facePath:"fendou.gif"},
		{faceName:"咒骂",facePath:"zhouma.gif"},
		{faceName:"疑问",facePath:"yiwen.gif"},
		{faceName:"嘘",facePath:"xu.gif"},
		{faceName:"晕",facePath:"yun.gif"},
		{faceName:"折磨",facePath:"zhemo.gif"},
		{faceName:"衰",facePath:"shuai.gif"},
		{faceName:"骷髅",facePath:"kulou.gif"},
		{faceName:"敲打",facePath:"qiaoda.gif"},
		{faceName:"再见",facePath:"zaijian.gif"},
		{faceName:"擦汗",facePath:"cahan.gif"},
		{faceName:"抠鼻",facePath:"koubi.gif"},
		{faceName:"鼓掌",facePath:"guzhang.gif"},
		{faceName:"糗大了",facePath:"caidao.gif"},
		{faceName:"坏笑",facePath:"huaixiao.gif"},
		{faceName:"左哼哼",facePath:"zuohengheng.gif"},
		{faceName:"右哼哼",facePath:"youhengheng.gif"},
		{faceName:"哈欠",facePath:"haqian.gif"},
		{faceName:"鄙视",facePath:"bishi.gif"},
		{faceName:"委屈",facePath:"weiqu.gif"},
		{faceName:"快哭了",facePath:"kuaikule.gif"},
		{faceName:"阴险",facePath:"yinxian.gif"},
		{faceName:"亲亲",facePath:"qinqin.gif"},
		{faceName:"吓",facePath:"xia.gif"},
		{faceName:"可怜",facePath:"kelian.gif"},
		{faceName:"菜刀",facePath:"caidao.gif"},
		{faceName:"西瓜",facePath:"xigua.gif"},
		{faceName:"啤酒",facePath:"pijiu.gif"},
		{faceName:"篮球",facePath:"lanqiu.gif"},
		{faceName:"乒乓",facePath:"pingpang.gif"},
		{faceName:"拥抱",facePath:"yongbao.gif"},
		{faceName:"握手",facePath:"woshou.gif"},
		{faceName:"得意地笑",facePath:"deyidexiao.gif"},
		{faceName:"听音乐",facePath:"tingyinyue.gif"}
	]
	,
	Init:function(){
		var isShowImg=false;
		$(".Input_text").unbind('focusout').focusout(function(){
			isShowImg=false;
			$(this).parent().css("border-color", "#cccccc");
            $(this).parent().css("box-shadow", "none");
            $(this).parent().css("-moz-box-shadow", "none");
            $(this).parent().css("-webkit-box-shadow", "none");
		});
		$(".Input_text").focus(function(){
		$(this).parent().css("border-color", "rgba(19,105,172,.75)");
        $(this).parent().css("box-shadow", "0 0 3px rgba(19,105,192,.5)");
        $(this).parent().css("-moz-box-shadow", "0 0 3px rgba(241,39,232,.5)");
        $(this).parent().css("-webkit-box-shadow", "0 0 3px rgba(19,105,252,3)");
		});
		$(".imgBtnPC").unbind().click(function(){
			if($(this).parent().prev().css("display") == "block"){
				isShowImg=true;
				$(this).parent().prev().css("display","none");
				$(this).parent().parent().prev().focus();
			}
			if(isShowImg==false){
				isShowImg=true;
				$(this).parent().prev().css("display","block");
				$(this).parent().prev().css("margin-top","36px");
			  $(this).parent().parent().prev().focus();
				if($(".faceDiv").children().length==0){
					for(var i=0;i<ImgIputHandler.facePath.length;i++){
						$(".faceDiv").append("<img onmouseover='onmous(this)' onmouseout='onmousout(this)' title=\""+ImgIputHandler.facePath[i].faceName+"\" src=\"img/"+ImgIputHandler.facePath[i].facePath+"\" />");
					}
					$(".faceDiv>img").click(function(){
				 		isShowImg=false;
			           $(this).parent().css("display","none");
						//ImgIputHandler.insertAtCursor($(this).parent().parent().prev()[0],"["+$(this).attr("title")+"]");
			           $(this).parent().parent().prev().append('<img title="'+$(this).attr('title')+ '" src="'+$(this).attr('src')+'" />');
					});
				}
			}else{
				isShowImg=false;
				$(this).parent().prev().css("display","none");
			}
		});
	
	},
	insertAtCursor:function(myField, myValue) {
    if (document.selection) {
        myField.focus();
        sel = document.selection.createRange();
        sel.text = myValue;
        sel.select();
    } else if (myField.selectionStart || myField.selectionStart == "0") {
        var startPos = myField.selectionStart;
        var endPos = myField.selectionEnd;
        var restoreTop = myField.scrollTop;
        myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
        if (restoreTop > 0) {
            myField.scrollTop = restoreTop;
        }
        myField.focus();
        myField.selectionStart = startPos + myValue.length;
        myField.selectionEnd = startPos + myValue.length;
    } else {
        myField.value += myValue;
        myField.focus();
    }
}
}
